﻿''' <summary>
''' 常量模块
''' </summary>
''' <remarks></remarks>
Public Module mdlEditor
    Public Const Application_Name As String = "MagicEditor"
    Public Const Application_Author As String = "WeiMin Hu"
    Public Const Application_Email As String = "mynightelfplayer@hotmail.com"
    Public Const Application_HomePage As String = "http://www.realfaye.com"
    Public Const Application_SourceControl As String = "http://texteditor.codeplex.com/"
    Public Const Application_Version As String = "Alpha1"
    ''' <summary>
    ''' 语言配置
    ''' </summary>
    ''' <remarks></remarks>
    Public LanguageDoc As New Xml.XmlDocument
    Enum TextMode
        Command = 0
        Text = 1
    End Enum
    ''' <summary>
    ''' 从语言文件中获取文本
    ''' </summary>
    ''' <param name="TextId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function GetTextInLanguageDoc(ByVal TextId As String, Optional ByVal Index As TextMode = TextMode.Command) As String
        Select Case Index
            Case TextMode.Command
                TextId &= "_Command"
            Case TextMode.Text
                TextId &= "_Text"
        End Select
        Dim strRtn As String = TextId
        Try
            strRtn = LanguageDoc.GetElementsByTagName(TextId).ItemOf(0).InnerText
        Catch ex As Exception
            'TODO 异常处理
        End Try
        Return strRtn
    End Function
    ''' <summary>
    ''' 编码枚举
    ''' </summary>
    ''' <remarks></remarks>
    Enum EnumEncoding
        ANSI = 0
        GB2312 = 1
        ShfitJIS = 2
        UTF8 = 3
    End Enum
    ''' <summary>
    ''' 配置
    ''' </summary>
    ''' <remarks></remarks>
    Public DefaultConfig As Config
End Module
''' <summary>
''' 配置类
''' </summary>
''' <remarks></remarks>
<Serializable()> _
Public Class Config
    Dim mMultiLanguage As String
    ''' <summary>
    ''' 多国语言
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MultiLanguage() As String
        Get
            Return mMultiLanguage
        End Get
        Set(ByVal value As String)
            mMultiLanguage = value
        End Set
    End Property
    Dim mCurrentEncoding As EnumEncoding
    ''' <summary>
    ''' 当前编码
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property CurrentEncoding() As EnumEncoding
        Get
            Return mCurrentEncoding
        End Get
        Set(ByVal value As EnumEncoding)
            mCurrentEncoding = value
        End Set
    End Property
    Dim mSpaceForTab As Byte
    ''' <summary>
    ''' TAB和空格的转换
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SpaceForTab() As Byte
        Get
            Return mSpaceForTab
        End Get
        Set(ByVal value As Byte)
            mSpaceForTab = value
        End Set
    End Property
    Dim mDefaultCodeConfig As String
    ''' <summary>
    ''' 默认代码配置
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DefaultCodeConfig() As String
        Get
            Return mDefaultCodeConfig
        End Get
        Set(ByVal value As String)
            mDefaultCodeConfig = value
        End Set
    End Property
    Dim mRecentFiles As New List(Of String)
    ''' <summary>
    '''最近使用文档
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property RecentFiles() As List(Of String)
        Get
            Return mRecentFiles
        End Get
        Set(ByVal value As List(Of String))
            mRecentFiles = value
        End Set
    End Property
    ''' <summary>
    ''' 清除最近使用文档
    ''' </summary>
    ''' <remarks></remarks>
    Sub ClearRecentFiles()
        mRecentFiles.Clear()
    End Sub
    ''' <summary>
    ''' 追加最近使用文档
    ''' </summary>
    ''' <remarks></remarks>
    Sub AddRecentFiles(ByVal FileName As String)
        If mRecentFiles.Contains(FileName) = False Then
            mRecentFiles.Add(FileName)
        End If
    End Sub
    Dim mDateFormat As String
    ''' <summary>
    ''' 日期格式
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DateFormat() As String
        Get
            Return mDateFormat
        End Get
        Set(ByVal value As String)
            mDateFormat = value
        End Set
    End Property
    Dim mTimeFormat As String
    ''' <summary>
    ''' 时间格式
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property TimeFormat() As String
        Get
            Return mTimeFormat
        End Get
        Set(ByVal value As String)
            mTimeFormat = value
        End Set
    End Property
End Class
